package day22.Compare;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.TreeSet;

public class Demo {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ShipComparator comparator = new ShipComparator();
		ArrayList<Ship> list = new ArrayList<Ship>();
		
		Ship sh = new Ship(400, 7, "Titanik");
		Ship sh1 = new Ship(4, 7, "Santa Marina");
		Ship sh2 = new Ship(49, 7, "Queen Marry");
		
		list.add(sh);
		list.add(sh1);
		list.add(sh2);
		
		System.out.println(list);
		
		Collections.sort(list, comparator);
		
		System.out.println(list);
		
		TreeSet set = new TreeSet();
		set.add(sh);
		set.add(sh1);
		set.add(sh2);
		
		for (Iterator<Ship> it = set.descendingIterator(); it.hasNext();){
			System.out.println(it.next());
		}
		
		// set.comparator(); //
		
		//HASH-Sets:
		System.out.println(sh.hashCode());
		HashSet hSet = new HashSet();
		
		hSet.add(sh);
		hSet.add(sh1);
		hSet.add(sh2);

	}

}
